package com.lb.juc;

import java.util.concurrent.*;

/**
 * @ClassName： ThreadPoolExcutorTest
 * @Description：
 * @Author: 蓝莲花
 * @Date： 2024/1/10 22:49
 * @Version： V1.0
 */
public class ThreadPoolExecutorTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                50,
                100,
                500,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(),
                new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread(r);
                        t.setName("测试~~~");
                        return t;
                    }
                },
                new ThreadPoolExecutor.AbortPolicy()
        );

        executor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("你好，线程池！");
            }
        });

        Future<Object> future = executor.submit(new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                return null;
            }
        });

        Object o = future.get();

    }
}
